﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TodoApp.Enum;
using TodoApp.GoodsModel;
using TodoApp.LiveShopSkuDTO;
using Volo.Abp.Domain.Repositories;

namespace TodoApp
{
    /// <summary>
    ///  商品 sku 实现服务接口 
    /// </summary>
    public class SkuService : Volo.Abp.Application.Services.ApplicationService, ISkuService
    {
        /// <summary>
        ///  注入 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>

        private readonly IRepository<LiveShopSku, int> _shopSkus;
        public SkuService(IRepository<LiveShopSku, int> shopSkus) {
            _shopSkus = shopSkus;
        }
        /// <summary>
        ///  删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task DeleteAsync(int id)
        {
            await _shopSkus.DeleteAsync(id);
        }
        /// <summary>
        ///  显示 
        /// </summary>
        /// <returns></returns>
        public async Task<List<LiveShopSkuShowDTO>> GetListAsync()
        {
            var str = await _shopSkus.GetListAsync();
            return ObjectMapper.Map<List<LiveShopSku>, List<LiveShopSkuShowDTO>>(str);
        }
        /// <summary>
        /// 添加 
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<ShopStatus> InsertAsync(LiveShopSkuAddDTO model)
        {
            await _shopSkus.InsertAsync(ObjectMapper.Map<LiveShopSkuAddDTO,LiveShopSku>(model));
            return ShopStatus.Succeed;
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<ShopStatus> UpdateAsync(LiveShopSkuShowDTO model)
        {

            await _shopSkus.UpdateAsync(ObjectMapper.Map<LiveShopSkuShowDTO, LiveShopSku>(model));
            return ShopStatus.Succeed;
        }
    }
}
